package pkleczek.bugbrain.laboratory.elements;

import android.graphics.Canvas;
import android.graphics.Point;

public abstract class Element {

	/**
	 * Position on the working area.
	 */
	private Point position = new Point();

	public Element() {
	}

	public Point getPosition() {
		return position;
	}

	public void setPosition(Point position) {
		this.position.set(position.x, position.y);
	}

	/**
	 * Sprawdza, element nachodzi na płytkę o zadanych współrzędnych.
	 * 
	 * @param p
	 * @return
	 */
	public boolean contains(Point p) {
		int halfSize = getSize() / 2;

		return (p.x >= position.x - halfSize - 1
				&& p.x <= position.x + halfSize
				&& p.y >= position.y - halfSize - 1 && p.y <= position.y
				+ halfSize);
	}

	public abstract void draw(Canvas canvas, int tileSize);

	/**
	 * Returns number of tiles per square side.
	 * 
	 * @return
	 */
	public abstract int getSize();
}
